﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Db4objects.Db4o;

namespace Yosca
{
    public class Database
    {
        private IObjectContainer _db;
        public IEnumerable<Invoice> result { set; get; }

        private static Database instance;


        public static Database Instance
        {
            get
            {
                if (instance == null)
                {
                    instance = new Database();
                }
                return instance;
            }
        }
        public IObjectContainer db
        {
			get { return _db; }
        }
        public Database()
        {
            Db4oFactory.Configure().ObjectClass(typeof(Customer)).ObjectField("name").Indexed(true);
            Db4oFactory.Configure().ObjectClass(typeof(Customer)).ObjectField("bAddress").Indexed(true);
            Db4oFactory.Configure().ObjectClass(typeof(Customer)).ObjectField("hPhone").Indexed(true);

            _db = Db4oFactory.OpenFile("database.db4o");
        }
    }
}
